<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <div id="app">
        <button @click="count++">我被点击了{{count}}次</button>

        <counter></counter>

        <bc></bc>


    </div>
    <script>
        //1.全局声明注册一个组件
        Vue.component("counter", {
            template: `<button @click="count++">我被点击了{{count}}次</button>`,
            data() {
                return {
                    count: 1
                }
            }
        });

        //2.局部声明一个组件
        const buttonCounter = {
            template: `<button @click="count++">我被点击了{{count}}次</button>`,
            data() {
                return {
                    count: 1
                }
            }
        }
        let vm = new Vue({
            el: "#app",
            data: {
                count: 1

            },
            components: {
                "bc": buttonCounter
            }
        });
    </script>
</body>

</html>